package com.trademark.script.methods;

import com.rsbuddy.script.methods.Menu;
import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.task.Task;
import com.rsbuddy.script.util.Random;
import com.rsbuddy.script.wrappers.Item;

public class Menus {

	/*
	 * @param item The item to be hovered over
	 * 
	 * @param action The action to be hovered
	 * 
	 * @param timeout The amount of time to hover the selected action
	 */
	public static void hoverAction(final Item item, final String action,
			final int timeout) {
		if (item != null) {
			if (item.getComponent().containsAction(action)) {
				int index = -1;
				if (!Menu.isOpen()) {
					item.click(false);
					Task.sleep(200, 300);
				} else if (Menu.isOpen()) {
					index = Menu.getIndex(action);
					Mouse.move(Random.nextInt((Mouse.getLocation().x - 10),
							(Mouse.getLocation().x + 10)),
							(Menu.getLocation().y + ((index * 16) + Random
									.nextInt(21, 36))));
					Task.sleep(timeout, timeout + Random.nextInt(100, 250));
				}
			}
		}
	}
}
